import Api from './api'
import { saveAs } from 'file-saver'
/**
 * 资源服务api
 */
export class ResourceApi extends Api {
  getInfo (fileUri) {
    return this.request({
      url: `${this.servicePath}/${this.modulePath}/info/${fileUri}`,
      method: 'get'
    })
  }

  download ({
    fileUri,
    fileName
  }) {
    return this.request({
      url: `${this.servicePath}/${this.modulePath}/${fileUri}`,
      method: 'get',
      responseType: 'blob'
    }).then(res => {
      saveAs(res, fileName)
    })
  }
}

export default new ResourceApi('resource')
